<template>
  <v-row justify="center">
    <v-dialog v-model="dialog" persistent max-width="290">
      <v-card>
        <v-card-title class="headline">{{ from.title }}</v-card-title>
        <v-card-text>{{ from.desc }}</v-card-text>
        <v-card-actions>
          <div class="flex-grow-1"></div>
          <v-btn color="green darken-1" text @click="NowHandle">现在处理</v-btn>
          <v-btn color="green darken-1" text @click="NotHandle">稍后处理</v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
  </v-row>
</template>
<script>
import {MessageHandle,URLP,GetWorkOrderFromInfo} from './../../api/api'
export default {
    data:()=>({
        dialog:false,
        from:{
            title:'',
            desc:'',
            audio:'',
            images:'',
            name:'',
            contact:'',
            time:'',
        },
    }),
    created:function(){
            var order_no = URLP("order_no")
            GetWorkOrderFromInfo(order_no,this.$cookies.get("authtoken"))
            .then((resp)=>{
                    var res = resp.data
                    if(res.code == 1){
                        this.from.name = res.data.name
                        this.from.contact = res.data.contact
                        this.from.time = res.data.time_slot
                        this.from.title = res.data.title
                        this.from.desc = res.data.desc
                        this.from.audio = res.data.audio
                        this.fromimages = res.data.images.split(",")
                        console.log(this.fromimages)
                        this.dialog = true
                        return
                    }
                    this.dialog = true
                    this.from.title = res.msg
                    this.$store.commit('setProgress',false)
                    return
                })
                .catch((err)=>{
                    this.$store.commit('setProgress',false)
                    this.$store.commit('setAlert',{icon:'close',text:err,show:true})
                })
    },
    methods:{
        NowHandle:function(){
            this.$store.commit('setProgress',true)
            MessageHandle(URLP("order_no"),this.$cookies.get("authtoken"))
            .then((resp)=>{
                var res = resp.data
                if( res.code == 1 ){
                    this.$store.commit('setProgress',false)
                    this.$store.commit('setAlert',{icon:'close',text:res.msg,show:true})
                    this.$router.push("/chat?order_no="+URLP("order_no")+"&staff=1")
                    console.log(res.data)
                    return
                }
                this.$store.commit('setProgress',false)
                this.$store.commit('setAlert',{icon:'close',text:res.msg,show:true})
                return
            })
            .catch((err)=>{
                this.$store.commit('setProgress',false)
                this.$store.commit('setAlert',{icon:'close',text:err,show:true})
            })
        },
        NotHandle:function(){
            wx.Close()
        }
    }
}
</script>

<style>

</style>